package com.zmn.oms.admin.controller.conf.attachment;


import com.zmn.oms.common.constant.OrderAttachmentCategoryTypeEnum;
import com.zmn.oms.common.dto.ResultDTO;
import com.zmn.oms.model.entity.conf.attachment.ConfOrderAttachment;
import com.zmn.oms.model.entity.conf.attachment.ConfOrderAttachmentQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

/**
 * 类描述：视频配置
 *
 * @author ligang
 * @date 2021/09/25 11:03
 */
@Controller
@RequestMapping("/conf/attachment/orderVideo")
@Slf4j
public class ConfOrderVideoController  extends ConfOrderAttachmentController {

    @RequestMapping(value = "/list")
    public ModelAndView list(ModelAndView mv) {
        mv.setViewName("conf/attachment/orderVideo/list");
        return mv;
    }

    /**
     * 查询列表 ajax
     */
    @RequestMapping(value = "/ajax/list")
    @ResponseBody
    public ResultDTO ajaxList(ConfOrderAttachmentQuery query) {
        query.setType(OrderAttachmentCategoryTypeEnum.VIDEO.getCode());
        return super.ajaxList(query);
    }

    /**
     * 查看/编辑
     *
     * @param mv
     * @param id
     * @return
     */
    @RequestMapping(value = "/addEdit")
    public ModelAndView detail(ModelAndView mv, Integer id) {
        super.detail(mv,id);
        mv.setViewName("conf/attachment/orderVideo/detail");
        return mv;
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save")
    @ResponseBody
    public ResultDTO save(@RequestBody ConfOrderAttachment conf) {
        return super.save(conf);
    }

    /**
     * 改是否审核
     */
    @RequestMapping(value = "/modifyNeedReview")
    @ResponseBody
    public ResultDTO modifyReview(ConfOrderAttachment conf) {
        conf.setUpdater(super.getCurrentStaff().getRealName());
        confOrderAttachmentBService.modifyConfReviewById(conf);
        return ResultDTO.success();
    }

    /**
     * 改是否必传
     */
    @RequestMapping(value = "/modifyMustUpload")
    @ResponseBody
    public ResultDTO modifyMustUpload(ConfOrderAttachment conf) {
        conf.setUpdater(super.getCurrentStaff().getRealName());
        confOrderAttachmentBService.modifyConfMustUploadById(conf);
        return ResultDTO.success();
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public ResultDTO delete(Integer id) {
        return super.delete(id);
    }

    /**
     * 改sort
     */
    @RequestMapping(value = "/modifySort")
    @ResponseBody
    public ResultDTO modifySort(ConfOrderAttachment conf) {
        conf.setUpdater(super.getCurrentStaff().getRealName());
        confOrderAttachmentBService.modifyConfSortById(conf);
        return ResultDTO.success();
    }

    /**
     * 示例视频上传
     *
     * @param file
     * @return
     */
    @RequestMapping(value = "/uploader")
    @ResponseBody
    public ResultDTO uploaderVideo(MultipartFile file) {
        return super.uploaderFile(file, "/oms/orderAttachment/video");
    }
}
